package com.sp.properties;

import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;

/**
 * 演示Properties的读取
 */
public class Properties02 {
    public static void main(String[] args) throws IOException {
        //1. 创建Properties对象
        Properties properties = new Properties();
        //2. 加载指定配置文件
        properties.load(new FileReader("chapter19_IO\\src\\mysql.properties"));
        //3. 把key-value输出到控制台
        properties.list(System.out);
        //4. 根据key获取对应的值
        String user = properties.getProperty("user");
        String pwd = properties.getProperty("pwd");
        String ip = properties.getProperty("ip");
        System.out.println("用户名: " + user);
        System.out.println("密码是: " + pwd);
        System.out.println("IP是: " + ip);
    }
}
